﻿#region Using directives
using Microsoft.VisualStudio.TestTools.UnitTesting;

using System.Collections.Generic;

using Weazel.Gezel.Model;
using Weazel.Gezel.Model.Errors;
using Weazel.Math;
#endregion

namespace Weazel.Gezel.Parser.Test.ErrorHandling
{
  [TestClass]
  public class TestFsmErrorHandling
  {
    [TestMethod]
    public void TestFsmErrorHandling1()
    {
      string description =
        "dp mydp { " +
        " reg rx : ns(1); " +
        " sfg exec1 {}    " +
        " sfg exec2 {}    " +
        " sfg dummy {}    " +
        "}                " +

        "fsm myctrl (mydp) {      " +
        " initial s1;             " +
        " state s2;               " +

        // note: missing terminating semicolon
        " @s1 if(rx) then (exec1, exec2) -> s2 " +
        "     else (exec2, exec1) -> s2;       " +

        // illegal, must specify atleast one sfg ..
        " @s2 -> s1; " +
        "}";
      
      List<ParseError> errors = new List<ParseError>();

      Model.Model model = ParseModel.Parse(ref errors, description);

      Assert.IsTrue(errors.Count > 0);

      Assert.AreEqual(ParseErrorType.UnexpectedTokenExpectedSingle, errors[0].ErrorType);

      // cannot check the second error here 
    }
  }
}
